package top.ninwoo.utils.entity;

import java.util.List;

public class OvsBridge {
    private String bridgeId;
    private List<BridgePort> ports;

    public String getBridgeId() {
        return bridgeId;
    }

    public void setBridgeId(String bridgeId) {
        this.bridgeId = bridgeId;
    }

    public List<BridgePort> getPorts() {
        return ports;
    }

    public void setPorts(List<BridgePort> ports) {
        this.ports = ports;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof OvsBridge) {
             OvsBridge bridge = (OvsBridge) obj;
             if(bridge.bridgeId.equals(this.bridgeId)) {
                 if (this.ports == null && bridge.ports == null) {
                     return true;
                 } else if (this.ports == null || bridge.ports == null) {
                     return false;
                 }
                 else if(this.ports.size() == bridge.ports.size()) {
                     for (int i = 0; i < this.ports.size(); i++) {
                         if(!this.ports.get(i).equals(bridge.ports.get(i))) {
                            return false;
                         }
                     }
                 }
                 return true;
             }
        }
        return false;
    }
}
